package doublepointer;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @Author: sfy
 * @Date: 2024/1/30 21:02
 * @Description: 判断子序列
 */
public class Main3 {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws IOException {
        String[] split = br.readLine().split(" ");
        int n = Integer.parseInt(split[0]);
        int m = Integer.parseInt(split[1]);
        String[] split1 = br.readLine().split(" ");
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(split1[i]);
        }
        String[] split2 = br.readLine().split(" ");
        int[] arr2 = new int[m];
        for (int i = 0; i < m; i++) {
            arr2[i] = Integer.parseInt(split2[i]);
        }
        //双指针
        int i = 0, j = 0;
        while (i < n && j < m) {
            if (arr[i] == arr2[j]) {
                i++;
            }
            j++;
        }
        if (i == n) System.out.println("Yes");
        else System.out.println("No");
    }
}
